<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
<script>
    var ids=new Array();
    for(var i=0;i<31;i++)
        {
            ids[i]=i+1;
        }
    function a()
    {
        

        ids.sort(function(a,b)
            {
                return Math.random()-0.5;
            }
        );
        for(var i=0;i<6;i++)
        {
            console.log(ids.shift());
        }
        console.log(ids);
        for(var i=0;i<6;i++)
        {
            document.write(ids[i]+"&nbsp");
        }
        document.write("<br/>");
        for(var i=0;i<1;i++)
        {
            console.log(ids.shift());
        }
        console.log(ids);
        for(var i=0;i<1;i++)
        {
            document.write(ids[i]+"&nbsp");
        }
    }
    
</script>
<input type="button" value="抽取学号" onclick="a()">
</body>
</html>